import { getCurrentInstance, ComponentInternalInstance,ComponentPublicInstance } from 'vue';

/** 实例拓展属性方法类型 */
export interface InstanceExtendsProps extends ComponentPublicInstance{
    /** 全局http请求 */
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    $http: (method: 'GET'|'POST',url: string,params?: any,headers?: any)=>Promise<any>;
}


/** 在函数组件setup中获取this */
export const useInstance = (): InstanceExtendsProps => {
    const { proxy } = getCurrentInstance() as ComponentInternalInstance;
    return proxy as InstanceExtendsProps
}